package com.wits.av;

import android.util.Log;

/**
 * Created by zhengboyuan on 2018-08-27.
 */

public class JniRtpSound {

    public static final int    INVALID_HANDLE = -1;

    static {
        try {
            Log.i("jni", "loading JniRtpSound library");
            System.loadLibrary("RtpSound");
            Log.i("jni", "load JniRtpSound done");
        } catch (UnsatisfiedLinkError e) {
            Log.e("jni", "failed to load JniRtpSound");
        }
    }

    /**
     * 初始化
     * @return 0 表示成功
     */
    public native static int rtpsound_init();

    /**
     * 反初始化
     * @return
     */
    public native static void rtpsound_quit();

    /**
     * 打开rtp播放器
     * @param port  本地传输端口
     * @param codec     音频编码
     * @param channels  音频通道数
     * @param samplerate    音频采样率
     * @return  句柄, -1 表示失败.
     */
    public native static int rtpsound_open(int port, int codec, int channels, int samplerate);

    /**
     * 关闭rtp播放器
     * @param handle
     */
    public native static void rtpsound_close(int handle);

    /**
     * 设置音量
     * @param handle
     * @param volume    音量, 取值范围[0,1]
     * @return
     */
    public native static boolean rtpsound_setVolume(int handle, float volume);

    /**
     * 获取音量
     * @param handle
     * @return 音量, 取值范围为[0,1]
     */
    public native static float rtpsound_getVolume(int handle);


}
